home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / unload1a / module1.bas < prev    next >
BASIC Source File  |  1999-10-21  |  3KB  |  52 lines

  1. Attribute VB_Name = "Module1"
  2.  
  3. Option Explicit
  4. Private Declare Function GetWindowDC Lib "user32" ( _
  5.     ByVal hwnd As Long) As Long
  6. Private Declare Function GetDesktopWindow Lib "user32" () As Long
  7. Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
  8. Private Declare Function BitBlt Lib "GDI32" (ByVal hDestDC As Long, _
  9. ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
  10. ByVal nHeight As Long, ByVal hSrcDC As Long, _
  11. ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long
  12. Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
  13.     ByVal hDC As Long) As Long
  14. Sub DoIt()
  15.     Dim hDC As Long, hwnd As Long, l As Long, t As Long, hw As Long, hh As Long, i As Integer
  16.     Dim hhp As Long, hwp As Long, tppx As Long, tppy As Long
  17.    
  18.     tppy = Screen.TwipsPerPixelY        ' get current twip/pixel conversion value
  19.     tppx = Screen.TwipsPerPixelX        ' get current twip/pixel conversion value
  20.     With Form1
  21.         l = .Left \ tppx               ' Convert form1 left to pixels
  22.         t = .Top \ tppy                ' convert form1 top to pixels
  23.         hh = .Height \ 2               ' get half-height
  24.         hw = .Width \ 2                ' get half-width (not half-wit!)
  25.         f1.Move .Left, .Top, hw, hh
  26.         f2.Move .Left + hw, .Top, hw, hh
  27.         f3.Move .Left, .Top + hh, hw, hh
  28.         f4.Move .Left + hw, .Top + hh, hw, hh
  29.     End With
  30.     hwnd = GetDesktopWindow()           ' get the Window handle for the desktop window
  31.     hDC = GetWindowDC(hwnd)             ' get a Device Context for the desktop window
  32.     hhp = hh \ tppy                     ' get half-height-in-pixels
  33.     hwp = hw \ tppx                     ' get half-width-in-pixels
  34.     BitBlt f1.hDC, 0, 0, hwp, hhp, hDC, l, t, vbSrcCopy             ' copy Upper Left qtr
  35.     BitBlt f2.hDC, 0, 0, hwp, hhp, hDC, l + hwp, t, vbSrcCopy       ' copy Upper Right qtr
  36.     BitBlt f3.hDC, 0, 0, hwp, hhp, hDC, l, t + hhp, vbSrcCopy       ' copy Lower Left qtr
  37.     BitBlt f4.hDC, 0, 0, hwp, hhp, hDC, l + hwp, t + hhp, vbSrcCopy ' copy Lower Right qtr
  38.     ReleaseDC hwnd, hDC                 ' release the DC (important)
  39.     Form1.Hide                          ' hide orig form
  40.     f1.Show: f2.Show: f3.Show: f4.Show  ' bring in the clones
  41.     For i = 0 To Form1.Left Step tppx   ' do something to them - fly apart for ex.
  42.         With f1:    .Move .Left - tppx, .Top - tppy:    End With
  43.         With f2:    .Move .Left + tppx, .Top - tppy:    End With
  44.         With f3:    .Move .Left - tppx, .Top + tppy:    End With
  45.         With f4:    .Move .Left + tppx, .Top + tppy:    End With
  46.         DoEvents
  47.     Next
  48.     Unload f1:    Unload f2:    Unload f3:    Unload f4
  49. End Sub
  50.  
  51.  
  52.